<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<script type="text/javascript" src="../../js/boot.js"></script>
	<title>页面定义</title>
</head>

<body>
	<fieldset id="fd1" style="width: 96%; margin-bottom: 10px;">
		<legend><span>查询条件</span></legend>
		<div id="queryForm" class="fieldset-body">
			<table class="form-table" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td class="form-label">
						<span>模板名称：</span>
						<input name="templetName" class="mini-textbox" style="width: 150px" />
						<input name="templetName_link" value="like" class="mini-hidden" style="width: 150px" />
						<a style="margin: 0 0 0 0;" class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
						<a class="mini-menubutton " menu="#popupMenu">新增</a>
						<a class="mini-button" iconCls="icon-add" onclick="doEdit()">编辑</a>
						<a class="mini-button" iconCls="icon-add" onclick="doDelete()">删除</a>
					</td>
				</tr>
			</table>
		</div>

		<ul id="popupMenu" class="mini-menu" style="display:none;">
			<li iconCls="icon-new" onclick="doAdd(1)">普通</li>
			<li iconCls="icon-new" onclick="doAdd(2)">Html页面</li>
			<li iconCls="icon-new" onclick="doAdd(3)">MiniUI页面</li>
		</ul>
	</fieldset>

	<div class="mini-fit">
		<div id="datagrid" class="mini-datagrid" style="width:100%;height:100%;" pageSize="20" idField="instID" allowResize="true" multiSelect="true">
			<div property="columns">
				<div type="checkcolumn" width="12"></div>
				<div type="indexcolumn" width="12"></div>
				<div field="tableID" visible="false"></div>
				<div field="fileName" headerAlign="center">文件名称</div>
				<div field="templatType" headerAlign="center">模板类型</div>
				<div field="templetName" headerAlign="center" width="80">模板名称</div>
				<div field="description" headerAlign="center" width="60">表名称</div>
				<div field="remark" headerAlign="center" width="60">说明</div>
			</div>
		</div>
	</div>
	<!--
	1、查询条件定义
		标题，
		名称，
		比较符：等于，小于，大于，小于等于，大于等于，相似，不等于，允许两个比较符
		数据类型：整型，字符串
		允许重复
		条件类型：
		顺序
	2、按钮定义：标题，名称，方法名称 ，方法定义，顺序
	3、列表定义：标题，名称，类型，顺序
	4、表单定义：标题，名称，类型，顺序
	5、模板输出定义
	-->
</body>

<script type="text/javascript">
	miniInit();

	var queryForm = new mini.Form("#queryForm"); // 查询条件表单
	var datagrid = mini.get("datagrid"); // 表定义列表

	/************************************************************************
	 * 表定义列表事件
	 ************************************************************************/
	datagrid.set({
		url: http.getUrl("/admin/page/page.do")
	});

	search();
	// 表定义查询方法
	function search() {
		var data = queryForm.getData(true, false);
		data.orderBy = "sequence asc";
		datagrid.load(data, null, miniui.showLoadErrorMessageBox);
	}

	// 新增页面定义
	function doAdd(type) {
		var url = "";
		if (type == 1) {
			url = ctx + '/admin/code/page_detail.html';
		} else if (type == 2) {
			var FrameTab = window.top.FrameTab;
			var tab = FrameTab.addTab("新建", ctx + "/admin/code/html/window_edit.html?d="+ (new Date()).getTime());
			//var sub = window.mini.get("新建");
			// setBody("/templet/html/empty.html");
			tab.onload = function () {
				var tabs = window.top.mini.get("main-tab");
				var iFrame = tabs.getTabIFrameEl(tab);
				iFrame.contentWindow.setBody("/admin/code/html/empty.html");
				// debugger
			}
			// debugger
			return;
		} else if (type == 3) { 
			var FrameTab = window.top.FrameTab;
			var tab = FrameTab.addTab("新建", ctx + "/admin/code/miniui/window_edit.html?d="+ (new Date()).getTime());
			//var sub = window.mini.get("新建");
			// setBody("/templet/html/empty.html");
			tab.onload = function () {
				var tabs = window.top.mini.get("main-tab");
				var iFrame = tabs.getTabIFrameEl(tab);
				iFrame.contentWindow.setBody("/admin/code/miniui/empty.html");
				// debugger
			}
			// debugger
			return;
		}
		var win = mini.open({
			title: '新增页面定义',
			url: url,
			//showModal: false,
			width: 1200,
			height: 600,
			onload: function () { },
			ondestroy: function (action) {
				datagrid.reload();
			}
		});
	}

	// 编辑页面定义
	function doEdit() {
		if (datagrid.getSelected() == null) {
			mini.alert("请选中需要编辑的数据", "提示", null);
			return;
		}
		var type = datagrid.getSelected().templatType;
		// debugger
		var url = "";
		if (type == "表格") {
			url = ctx + '/admin/code/page_detail.html';
		} else if (type == "表单") { } else if (type == "组合") { }
		var win = mini.open({
			title: '编辑页面定义',
			url: url,
			width: 1200,
			height: 600,
			onload: function () {
				var iframe = this.getIFrameEl();
				var data = datagrid.getSelected();
				iframe.contentWindow.setData(data);
			},
			ondestroy: function (action) {
				datagrid.reload();
			}
		});
	}

	// 编辑页面定义
	function doDelete() {
		if (datagrid.getSelected() == null) {
			mini.alert("请选中需要删除的数据行", "提示", null);
			return;
		}

		mini.confirm("确认删除该数据信息吗？", "删除操作", function (e) {
			if (e == "ok") {
				mini.mask({
					el: document.body,
					cls: 'mini-mask-loading',
					html: '数据删除中...'
				});
				var pageID = datagrid.getSelected().pageID;
				var data = {
					"pageID": pageID
				};
				http.post("/admin/page/delete.do", data, function (page) {
					mini.unmask();
					mini.alert("删除成功", "提示", null);
					datagrid.reload();
				});
			}
		});
	}
</script>

</html>